package com.tr.rentcar.controller.houtai.discount;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tr.rentcar.model.dao.DiscountDao;

/**
 * Servlet implementation class DiscountXGControllr
 */
@WebServlet("/houdiscountxg")
public class DiscountXGControllr extends HttpServlet {
	/**
	 * 后台修改优惠劵
	 */
	private static final long serialVersionUID = 1L;
	DiscountDao d=new DiscountDao();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String dname=request.getParameter("dname");
		String dtime=request.getParameter("dtime");
		String dpicture=request.getParameter("dpicture");
		String dnum=request.getParameter("dnum");
		String ddiscount=request.getParameter("ddiscount");
		String did=request.getParameter("did");
		request.setAttribute("dname", dname);
		request.setAttribute("dtime", dtime);
		request.setAttribute("dpicture", dpicture);
		request.setAttribute("dnum", dnum);
		request.setAttribute("ddiscount", ddiscount);
		request.setAttribute("did", did);
		request.getRequestDispatcher("/WEB-INF/jsp/houtai_discountxg.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String did=request.getParameter("did");
		String dname=request.getParameter("dname");
		String dtime=request.getParameter("dtime");
		String dpicture=request.getParameter("dpicture");
		String dnum=request.getParameter("dnum");
		String ddiscount=request.getParameter("ddiscount");
		//System.out.println(did);
		PrintWriter out=response.getWriter();
		try {
			if (d.xgbyid(dname, dtime, dnum, ddiscount, did)) {
				out.println("修改成功");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
